﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Ljy_VoteSys.Models.Database
{
    public partial class Ljy_VoteSysContext : DbContext
    {
        public Ljy_VoteSysContext()
        {
        }

        public Ljy_VoteSysContext(DbContextOptions<Ljy_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<CompanyDetail> CompanyDetails { get; set; }
        public virtual DbSet<CompanyUser> CompanyUsers { get; set; }
        public virtual DbSet<Ticket> Tickets { get; set; }
        public virtual DbSet<UserTable> UserTables { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Ljy_VoteSys;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<CompanyDetail>(entity =>
            {
                entity.HasKey(e => e.Testid)
                    .HasName("PK_CompanyDetail_1");

                entity.ToTable("CompanyDetail");

                entity.Property(e => e.Testid)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasColumnName("testid");

                entity.Property(e => e.CompanyIntroduce)
                    .IsRequired()
                    .HasMaxLength(255)
                    .IsUnicode(false);

                entity.Property(e => e.CompanyLogoUrl)
                    .IsRequired()
                    .IsUnicode(false);

                entity.Property(e => e.CompanyName)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.CompanyUser)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.IsShow).HasColumnName("isShow");

                entity.Property(e => e.Level)
                    .IsRequired()
                    .HasMaxLength(3)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<CompanyUser>(entity =>
            {
                entity.HasKey(e => e.CompanyUser1);

                entity.ToTable("CompanyUser");

                entity.Property(e => e.CompanyUser1)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("CompanyUser");

                entity.Property(e => e.Pwd)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("pwd");

                entity.Property(e => e.Solt)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("solt");
            });

            modelBuilder.Entity<Ticket>(entity =>
            {
                entity.HasKey(e => e.Itemid)
                    .HasName("PK__Ticket__727D8793CDE88E62");

                entity.ToTable("Ticket");

                entity.Property(e => e.CompanyName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<UserTable>(entity =>
            {
                entity.HasKey(e => e.Username)
                    .HasName("PK_User");

                entity.ToTable("UserTable");

                entity.Property(e => e.Username)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Pwd)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("pwd");

                entity.Property(e => e.Solt)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("solt");

                entity.Property(e => e.TicketOneday).HasDefaultValueSql("((5))");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
